function Food(ele){
    this.ele = ele
    this.len  = 20
    this.foodObj = null
    this.foodX = 0
    this.foodY = 0
}
Food.prototype.create = function(){
    // 2-设置样式（w20/h20/bgreen/position:absolute）
    let divObj = document.createElement('div')
    divObj.style.width = this.len + 'px'
    divObj.style.height = this.len + 'px'
    divObj.style.background = 'green'
    divObj.style.position = 'absolute'
   
    this.foodObj = divObj
    // 3-在页面展示
    this.ele.appendChild(divObj)
    this.Move()


} 
Food.prototype.Move = function(){
    let MaxW = this.ele.clientWidth / this.len -1
    let MaxH = this.ele.clientHeight / this.len -1

    this.foodX = Math.floor(Math.random()*(MaxW+1)) * this.len
    this.foodY = Math.floor(Math.random()*(MaxH+1)) * this.len

    this.foodObj.style.left = this.foodX +'px'
    this.foodObj.style.top = this.foodY +'px'

}